#include<iostream>
#include<string>
#include<map>
using namespace std;
typedef pair<int, int> PII;
const int N = 1e3 + 10;
map<char, int>st;
map<pair<int,char>, int>mp1;
struct Yesde
{
	int t, id;
	char c;
	string ans;
}s[N];
int n, t, m;
int main()
{
	cin >> n >> t >> m;
	for (int i = 0; i < m; i++) {
		int t, id;
		char c;
		string ans;
		cin >> t >> id;
		cin >> c;
		cin >> ans;
		s[i] = { t,id,c,ans };
	}
	for (int i = 1; i <= t; i++) {
		for (int j = 0; j < n; j++) {
			mp1[{i, j + 'A'}] = 0;
		}
	}
	for (int i = 0; i < m; i++) {
		if (s[i].ans == "Yes") {
			if (mp1[{s[i].id, s[i].c}]) {
				continue;
			}
			mp1[{s[i].id, s[i].c}] = s[i].t;
			st[s[i].c] = 1;
		}
	}
	for (int i = 0; i < n; i++) {
		char k = 'A' + i;
		cout << k << " ";
		if (st[k]) {
			int ans1 = 0;
			int ans2 = 0;
			for (int j = 1; j <= t; j++) {
				if (mp1[{j, k}] > ans1) {
					ans1 = mp1[{j, k}];
					ans2 = j;
				}
			}
			cout << ans1 << " " << ans2 << endl;
		}
		else {
			cout << "- -" << endl;
		}
	}
	return 0;
}